<?php
declare (strict_types = 1);

namespace app\admin\validate;

use think\Validate;

class Category extends Validate
{
    protected $scene = [
        'save' => ['name', 'pid'],
        'listorder' => ['id', 'listorder'],
    ];

    /**
     * 定义验证规则
     * 格式：'字段名' =>  ['规则1','规则2'...]
     *
     * @var array
     */
    protected $rule = [
        'id'   => 'require|min:1',
        'name' => 'require',
        'pid'  => 'require',
        'listorder' => 'require',
    ];

    /**
     * 定义错误信息
     * 格式：'字段名.规则名' =>  '错误信息'
     *
     * @var array
     */
    protected $message = [
        'id.require'   => '参数错误',
        'id.min'       => '参数错误',
        'name.require' => '分类名称不可为空',
        'pid.require'  => '父级分类不可为空',
        'listorder.require' => '排序不可为空',
    ];
}
